var https = require('https');
var fs = require('fs');
var options = {
	hostname:'wuyongping',
	port:443,
	path:'/users',
	method:'GET',
	key:fs.readFileSync('../ssl/client-key.pem'),
	cert:fs.readFileSync('../ssl/client.crt'),
	ca: [fs.readFileSync('../ssl/ca.crt')],
	agent:false,
	
	checkServerIdentity: function (host, cert) {
    // It can be useful to resolve both parts to IP or to Hostname (with some synchronous resolver (I wander why they did not add done() callback as the third parameter)).
    // Be carefull with SNI (when many names are bound to the same IP).
    if (host != cert.subject.CN)
      return host+'Incorrect server identity'+cert.subject.CN;// Return error in case of failed checking.
      // Return undefined value in case of successful checking.
      // I.e. you could use empty function body to accept all CN's.
  }
  
};
options.agent = new https.Agent(options);
var req = https.request(options,function(res){
	console.log("statusCode: ", res.statusCode);
	console.log("headers: ", res.headers);
	res.setEncoding('utf-8');
	res.on('data',function(d){
		console.log(d);
 })
});
req.end();
req.on('error',function(e){
	console.log(e);
})